package stalker;

import message.Message;
import message.controller.MessageController;
import message.visitor.singleton.StalkerManagerMessageVisitor;

public class StalkerManager extends Stalker {
  
  private final MessageController<Void> controller_;
  
  private void checkRep() {
    assert (controller_ != null) :
      "Room: fields must not be null";
    assert (Stalker.getStalker(this.getID()) == this) :
      "Room: Inconsistent data";
  }
  
  /**
   * Creates a new empty room
   * 
   * @requires name is not null, name is unique
   * @param name Name of this room.
   */
  
  public StalkerManager() {
    super("Stalker Manager");
    controller_ = new MessageController<Void>(new StalkerManagerMessageVisitor());
    new Thread(controller_).start();
    checkRep();
  }
  
  /**
   * Accepts a request
   * @requires request not null
   * @param request A request made to the room
   */
  @Override
  public void acceptMessage(Message message) {
    assert message != null;
    controller_.enqueueMessage(message);
  }
  
}
